/*
 * This file is part of the Boring Engine.
 *
 * Copyright (c) 2011 by pf5234 <pf5234@users.sourceforge.net>.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

package com.googlecode.boringengine.internal;

import com.googlecode.boringengine.Sprite;

public abstract class Renderer {

    protected int _x, _y; // Position, in pixels
    protected double _scale = 1; // Scale factor
    protected double _rotation; // Rotation, in degrees
    protected boolean _flip;
    protected int _alpha = 255;

    protected Renderer() { }

    public void setPosition(int x, int y) {
        _x = x;
        _y = y;
    }

    public void moveOverWithScale(int x, int y) {
        _x += x * _scale;
        _y += y * _scale;
    }

    public void moveOverWithoutScale(int x, int y) {
        _x += x;
        _y += y;
    }

    public void setScale(double scale) {
        _scale = scale;
    }

    public void addScale(double scale) {
        _scale *= scale;
    }

    public void setRotation(double rotation) {
        _rotation = rotation;
    }

    public void addRotation(double rotation) {
        _rotation += rotation;
    }

    public void setFlip(boolean flip) {
        _flip = flip;
    }

    public void addFlip(boolean flip) {
        _flip = _flip != flip;
    }

    public void setAlpha(int alpha) {
        _alpha = alpha < 0 ? 0 : alpha > 255 ? 255 : alpha;
    }

    public int getX() {
        return _x;
    }

    public int getY() {
        return _y;
    }

    public double getScale() {
        return _scale;
    }

    public double getRotation() {
        return _rotation;
    }

    public boolean isFlipped() {
        return _flip;
    }

    public int getAlpha() {
        return _alpha;
    }

    public abstract void clearScreen();
    public abstract void clip(int x, int y, int width, int height);
    public abstract Sprite createSpriteFromScreen(int x, int y, int width, int height);
    public abstract Sprite createSprite(String sprite, int width, int height);
    public abstract void drawRect(int w, int h, int color);
    public abstract void drawSprite(Sprite sprite);
    public abstract boolean takeScreenshot(String screenshotName);
    public abstract void uploadSprites();
    public abstract void unClip();
}
